import request from '@/config/axios'

// ERP 产品库存 VO
export interface StockVO {
  // 编号
  id: number
  // 产品编号
  productId: number
  // 仓库编号
  warehouseId: number
  // 库存数量
  count: number
}
export interface StockConfigVO {
  id:string,
  dictCode: string
  description: string
  isEnabled: string
  isCustomer: string 
}

export interface DictItemConfigVO {
  id:string,
  value: string
  description: string
  isEnabled: string
  sort: string 
  dictId:string
}
// ERP 产品库存 API
export const StockApi = {
  // 查询产品库存分页
  getStockPage: async (params: any) => {
    return await request.get({ url: `/erp/stock/page`, params })
  },

  // 新增通用字段
  createStockConfig: async (data: StockConfigVO) => {
    return await request.post({ url: `/erp/sys-dict/create`, data })
  },
 // 新增通用字段
  createSysDictItemConfig: async (data: StockConfigVO) => {
    return await request.post({ url: `/erp/sys-dict-item/create`, data })
  },
  // 根据字典码获取字典项
   getByDictCode: async (params:any) => {
    return await request.get({ url: `erp/sys-dict-item/getByDictCode`, params })
  },
  // 查询通用字典分页
  getSysDictPage: async (params: any) => {
    return await request.get({ url: `/erp/sys-dict/page`, params })
  },
   // 查询通用字典项分页
  getSysDictItemPage: async (params: any) => {
    return await request.get({ url: `/erp/sys-dict-item/page`, params })
  },
  // 修改通用字典分类
  updateSysDict: async (data: StockConfigVO) => {
    return await request.put({ url: `/erp/sys-dict/update`, data })
  },
  // 修改通用字典分类
  updateSysDicItem: async (data: DictItemConfigVO) => {
    return await request.put({ url: `/erp/sys-dict-item/update`, data })
  },
  // 删除通用字典分类
  deleteSysDict: async (id: number) => {
    return await request.delete({ url: `/erp/sys-dict/delete?id=` + id })
  },
  // 删除通用字典项
  deleteSysDictItem: async (id: number) => {
    return await request.delete({ url: `/erp/sys-dict-item/delete?id=` + id })
  },
  // 删除多个字典
  deleteSysDictList: async (ids: any[]) => {
    return await request.delete({ url: `/erp/sys-dict/delete-list`, params: { ids: ids.join(',') } })
  },

  // 查询通用字典详情
  getSysDict: async (id: number) => {
    return await request.get({ url: `/erp/sys-dict/get?id=` + id })
  },

  // 导出产品库存明细 Excel
  exportSysDict: async (params) => {
    return await request.download({ url: `/erp/sys-dict/export-excel`, params })
  },
  // 查询产品分页
  getMartaialPage: async (params: any) => {
    return await request.get({ url: `/erp/stock/page`, params })
  },
  // 查询产品库存详情
  getStock: async (id: number) => {
    return await request.get({ url: `/erp/stock/get?id=` + id })
  },

  // 查询产品库存详情
  getStock2: async (productId: number, warehouseId: number) => {
    return await request.get({ url: `/erp/stock/get`, params: { productId, warehouseId } })
  },

  // 获得产品库存数量
  getStockCount: async (productId: number) => {
    return await request.get({ url: `/erp/stock/get-count`, params: { productId } })
  },

  // 导出产品库存 Excel
  exportStock: async (params) => {
    return await request.download({ url: `/erp/stock/export-excel`, params })
  }
}
